import { message } from "antd";
import axios from "axios";
import { appDispatch } from "@/store";
import { changeIsLoading } from "@/store/modules/common";
const sytRequest = axios.create({
    baseURL:"/syt/admin"
})
// 请求拦截
sytRequest.interceptors.request.use(config=>{
    // 将common->isLoading的状态值晚改为true
    // appDispatch(changeIsLoading(true));
    return config;
});
// 响应拦截
sytRequest.interceptors.response.use((res:any)=>{
    // 将将common->isLoading的状态值晚改为false
    // appDispatch(changeIsLoading(false));
    // 如果成功获得数据
    if(res.data.code === 200)
        return res.data.data;
    else{
        message.error(res.data.message);
        return Promise.reject(res.data.message);
    }
});
export default sytRequest;